function setCookie(name,value,date,path){
				var str =name+"="+value;
				//判断用户在使用这个方法是，是否传入了第三个参数
				if(date){
					var dt = new Date();
					dt.setDate(dt.getDate()+date);
					str += ";expires="+dt.toGMTString();
				}
				//如果用户在使用这个方法时，判断是否传入了第四个参数
				if(path){
					str += ";path="+path;
				}
				//alert(str)
				//设置cookie
				document.cookie = str;
		}
		
			function getCookie(name) //获取cookie
			{
				if(document.cookie.length > 0) {
					c_start = document.cookie.indexOf(name + "=");
					if(c_start != -1) {
						c_start = c_start + name.length + 1;
						//console.log(c_start)
						c_end = document.cookie.indexOf(";", c_start);
						//console.log(c_end)
						if(c_end == -1) c_end = document.cookie.length;
						return unescape(document.cookie.substring(c_start, c_end));
					}
				}
				return "";
			}

			function checkCookie() //检查cookie是否存在，若存在，读取出来
			{
				var username = document.getElementById("username");
				var password = document.getElementById("password");
				//console.log(userName.id);
				var UValue = getCookie(username.id);
				var PValue = getCookie(password.id);
				if(UValue != null && UValue != "" && PValue != null && PValue != "") {
					username.value = UValue;
					password.value = PValue;
				}
			}

			function saveCookie() { //保存cookie
				var UName = document.getElementById("username");
				var PName = document.getElementById("password");
				if(UName.value == "") {
					alert("请输入用户名！");
				} else if(PName.value == "") {
					alert("请输入密码！");
				} else if(confirm("是否保存用户名密码？")) {
					setCookie(UName.id, UName.value, 30);
					setCookie(PName.id, PName.value, 30);
				}
			}